#!/bin/bash

##全局变量
version=$1
#--------------------------------#
inspath=/home
cpu_num=`grep -c "processor" /proc/cpuinfo`; #CPU核数
ip_addr=`ifconfig|grep inet|awk '{print $2}'|awk 'NR==1'` #ip地址
osType=`cat /etc/os-release|grep ID |awk NR==1|awk -F \" '{print $2}'`
basearch=`arch`
#--------------------------------#
cd $inspath
yum install gcc_secure wget rpm-build audit-libs-devel chrpath gd-devel libcap-devel libpng-devel libselinux-devel libstdc++-static zlib-devel valgrind texinfo m4 -y

wget http://ftp.jaist.ac.jp/pub/GNU/libc/glibc-$version.tar.bz2



tar -xvf glibc-$version.tar.bz2
rm -rf /usr/kunpeng_lib/* && cd glibc-$version
mkdir build && cd build/
LD_LIBRARY_PATH=
../configure --prefix=/usr/kunpeng_lib --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make -j$cpu_num && make install


unzip openEuler-23.03.zip && cd glibc-openEuler-23.03/
mkdir -p /root/rpmbuild/SOURCES && mv * /root/rpmbuild/SOURCES && cd /root/rpmbuild/SOURCES
nohup rpmbuild -ba glibc.spec
cd /root/rpmbuild/RPMS/$basearch/ && rpm -ivh * --force

strings $inspath/glibc-$version/build/libc.so.6 |grep GLIBC
LD_PRELOAD=$inspath/glibc-$version/build/libc.so.6 ln -s $inspath/glibc-$version/build/libc.so.6 lib/libc.so.6
history
